﻿--
-- Dropping stored procedure pr_NhanVien_SelectAll : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_NhanVien_SelectAll]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_NhanVien_SelectAll]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_NhanVien_SelectAll
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:43 PM
-- Description:	This stored procedure is intended for selecting all rows from NhanVien table
-- ==========================================================================================
Create Procedure pr_NhanVien_SelectAll
As
Begin
	Select 
		[MaNV],
		[TenNV],
		[GioiTinh],
		[NgaySinh],
		[SoCMND],
		[NgayVaoLam],
		[ChucVu],
		[DiaChi],
		[SDT],
		[TenDangNhap],
		[MatKhau]
	From NhanVien
End

GO


--
-- Dropping stored procedure pr_NhanVien_SelectRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_NhanVien_SelectRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_NhanVien_SelectRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_NhanVien_SelectRow
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:43 PM
-- Description:	This stored procedure is intended for selecting a specific row from NhanVien table
-- ==========================================================================================
Create Procedure pr_NhanVien_SelectRow
	@MaNV varchar(10)
As
Begin
	Select 
		[MaNV],
		[TenNV],
		[GioiTinh],
		[NgaySinh],
		[SoCMND],
		[NgayVaoLam],
		[ChucVu],
		[DiaChi],
		[SDT],
		[TenDangNhap],
		[MatKhau]
	From NhanVien
	Where
		[MaNV] = @MaNV
End

GO


--
-- Dropping stored procedure pr_NhanVien_Insert : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_NhanVien_Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_NhanVien_Insert]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_NhanVien_Insert
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:43 PM
-- Description:	This stored procedure is intended for inserting values to NhanVien table
-- ==========================================================================================
Create Procedure pr_NhanVien_Insert
	@MaNV varchar(10),
	@TenNV nvarchar(50),
	@GioiTinh nvarchar(10),
	@NgaySinh datetime,
	@SoCMND varchar(50),
	@NgayVaoLam datetime,
	@ChucVu nvarchar(50),
	@DiaChi nvarchar(200),
	@SDT varchar(50),
	@TenDangNhap nvarchar(50),
	@MatKhau varchar(50)
As
Begin
	Insert Into NhanVien
		([MaNV],[TenNV],[GioiTinh],[NgaySinh],[SoCMND],[NgayVaoLam],[ChucVu],[DiaChi],[SDT],[TenDangNhap],[MatKhau])
	Values
		(@MaNV,@TenNV,@GioiTinh,@NgaySinh,@SoCMND,@NgayVaoLam,@ChucVu,@DiaChi,@SDT,@TenDangNhap,@MatKhau)

End

GO


--
-- Dropping stored procedure pr_NhanVien_Update : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_NhanVien_Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_NhanVien_Update]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_NhanVien_Update
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:43 PM
-- Description:	This stored procedure is intended for updating NhanVien table
-- ==========================================================================================
Create Procedure pr_NhanVien_Update
	@MaNV varchar(10),
	@TenNV nvarchar(50),
	@GioiTinh nvarchar(10),
	@NgaySinh datetime,
	@SoCMND varchar(50),
	@NgayVaoLam datetime,
	@ChucVu nvarchar(50),
	@DiaChi nvarchar(200),
	@SDT varchar(50),
	@TenDangNhap nvarchar(50),
	@MatKhau varchar(50)
As
Begin
	Update NhanVien
	Set
		[TenNV] = @TenNV,
		[GioiTinh] = @GioiTinh,
		[NgaySinh] = @NgaySinh,
		[SoCMND] = @SoCMND,
		[NgayVaoLam] = @NgayVaoLam,
		[ChucVu] = @ChucVu,
		[DiaChi] = @DiaChi,
		[SDT] = @SDT,
		[TenDangNhap] = @TenDangNhap,
		[MatKhau] = @MatKhau
	Where		
		[MaNV] = @MaNV

End

GO


--
-- Dropping stored procedure pr_NhanVien_DeleteRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_NhanVien_DeleteRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_NhanVien_DeleteRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_NhanVien_DeleteRow
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:43 PM
-- Description:	This stored procedure is intended for deleting a specific row from NhanVien table
-- ==========================================================================================
Create Procedure pr_NhanVien_DeleteRow
	@MaNV varchar(10)
As
Begin
	Delete NhanVien
	Where
		[MaNV] = @MaNV

End

GO
